<?php

namespace support\Service;

use support\Backend\BackendService;
use support\Container;
use support\Db;
use support\Model\FileModel;

class FileService extends BackendService
{

    public function __construct()
    {
        $this->model = Container::get(FileModel::class);
    }

    public function getCountByWhere($where)
    {
        return $this->model->getCountByWhere($where);
    }

    public function getSumByWhere($filed, $where)
    {
        return $this->model->where($where)->sum($filed);
    }

    public function getCountByGroup($where)
    {
        return $this->model->select(['type', Db::raw('count(id) as number'), Db::raw('sum(length) as size')])->where($where)->groupBy('type')->get();
    }


}